<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    li {
      list-style: circle;
      cursor: pointer;
    }

    .sec {
      display: none;
      background: skyblue;
    }
  </style>
</head>

<body>
  <div id="content">
    <ul>
      <li>
        <h2>商城</h2>
        <div class="sec">
          <p>手机</p>
          <p>电脑</p>
          <p>打火机</p>
        </div>
      </li>
      <li>
        <h2>饭店</h2>
        <div class="sec">
          <p>烧烤</p>
          <p>腰子</p>
          <p>钣金</p>
        </div>
      </li>
      <li>
        <h2>服装</h2>
        <div class="sec">
          <p>裤子</p>
          <p>羽绒服</p>
          <p>袜子</p>
        </div>
      </li>
    </ul>
  </div>
  <script src="jquery-3.4.1.min.js"></script>
  <script>
    $("h2").click(function () {
      $(this).next().slideToggle(500)
      $(this).parent().siblings().find(".sec").slideUp()
    })


  </script>
</body>

</html>